//
//  BNRViewController.m
//  Quiz
//
//  Created by YaoJacob on 15/10/31.
//  Copyright © 2015年 Roger. All rights reserved.
//

#import "BNRViewController.h"

@interface BNRViewController ()

@property (nonatomic) int currentQuestionIndex;
@property (nonatomic, copy) NSArray *questions;
@property (nonatomic, copy) NSArray *answers;

@property (nonatomic, weak) IBOutlet UILabel *questionLabel;
@property (nonatomic, weak) IBOutlet UILabel *answerLabel;

@end

@implementation BNRViewController

-(instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
    if (self) {
        self.questions = @[@"what is 1+1?",
                           @"what is home?",
                           @"what is love?"];

        self.answers = @[@"2",
                           @"昆明路",
                           @"home。"];
        
        self.tabBarItem.title = @"猜猜看";
        self.tabBarItem.image = [UIImage imageNamed:@"credit7"];
    }
    return self;
}

-(int)getCurrentIndex
{
    self.currentQuestionIndex ++;
    if (self.currentQuestionIndex == self.questions.count) {
        self.currentQuestionIndex = 0;
    }
    
    return self.currentQuestionIndex;
}

-(IBAction)showQuestion:(id)sender
{
    self.questionLabel.text = self.questions[self.getCurrentIndex];
    self.answerLabel.text = @"???";
}

-(IBAction)showAnswer:(id)sender
{
    self.answerLabel.text = self.answers[self.currentQuestionIndex];

}
@end
